<template>
  <div class="app-container">
    <router-view />
  </div>
</template>

<script>
export default {
  name: "App",
  data() {
    return {
      exitAppTicker: 0
    };
  },
  mounted() {
    document.addEventListener("deviceready", () => {
      document.addEventListener("backbutton", () => {
        if (this.$route.meta.root) {
          if (this.exitAppTicker == 0) {
            this.exitAppTicker++;
            this.$toast({ message: "再点一次退出", position: 'bottom' });
            setTimeout(() => {
              this.exitAppTicker = 0;
            }, 1500);
          } else if (this.exitAppTicker == 1) {
            navigator.app.exitApp(); //退出app
          }
        } else {
          this.$router.back();
        }
      }, false);
    }, false);
  },
};
</script>

<style lang="scss" scoped>
.app-container {
  height: 100vh;
  background-color: rgb(244, 245, 246);
}
</style>